// Written by Craig'n'Dave
using System;
// Stack using an array
namespace ConsoleApp1
{
    class Program
    {
        public class Stack
        {
            private static int max = 10;
            private static string[] items = new string[max];

            private static int stack_pointer = -1;

            public bool push(string item)
            {
                // Check stack overflow
                if (stack_pointer < max)
                {
                    stack_pointer = stack_pointer + 1;
                    // Push the item
                    items[stack_pointer] = item;
                    return true;
                }
                else
                {
                    return false;
                }
            }

            public string pop()
            {
                // Check queue underflow
                if (stack_pointer != -1)
                {
                    // Pop the item
                    string item = items[stack_pointer];
                    stack_pointer = stack_pointer - 1;
                    return item;
                }
                else
                {
                    return null;
                }
            }

            public string peek()
            {
                // Check queue underflow
                if (stack_pointer != -1)
                {
                    // Peek the item
                    return items[stack_pointer];
                }
                else
                {
                    return null;
                }
            }
        }

        // Main program starts here
        static void Main(string[] args)
        {
            string[] items = new string[] { "Florida", "Georgia", "Delaware", "Alabama", "California" };
            Stack s = new Stack();
            // Add items to the stack
            for (int index = 0; index < items.Length; index++)
            {
                s.push(items[index]);
            }
            // Remove items from the stack
            Console.WriteLine(s.pop());
            // Output the next item in the stack
            Console.WriteLine(s.peek());
        }
    }
}
